package text;

import java.util.Arrays;
import java.util.Scanner;

public class ava {
    public static double max(double x,double y){
        return (x>y?x:y);
    }
    public static double max(double x,double y,double z){
        double ret1 = max(x,y);
        double ret2 = max(ret1,z);
        return ret2;
    }
    public static int max(int x,int y){
        return (x>y?x:y);
    }
    public static void main(String[] args) {
        /*求最大值方法的重载
        在同一个类中定义多个方法：要求不仅可以求2个整数的最大值，还可以求3个小数的最大值？*/
       int ret1 = max(2,3);
       double ret2 = max(3.14,3.5,6.1);
        System.out.println(ret1+"   "+ret2);

    }
    public static int add(int x,int y){
        return x+y;
    }
    public static  double add(double x,double y,double z){
        return x+y+z;
    }
    public static void main6(String[] args) {
        /*求和的重载
        在同一个类中,分别定义求两个整数的方法 和 三个小数之和的方法。
        并执行代码，求出结果*/
        int num1 = 30,num2 = 13;
        double n1 = 3.0,n2 = 5.0,n3 = 1.0;
        int sum1 = 0;
        double sum2 = 0;
        sum1 = add(num1,num2);
        sum2 = add(n1,n2,n3);
        System.out.println(sum1);
        System.out.println(sum2);
    }
    public static void main5(String[] args) {
        //求斐波那契数列的第n项。(迭代实现)---->不断变换初始值
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int n1 = 1,n2 = 1,n3 = 0;
        for (int i = 3; i <=n ; i++) {
            n3 = n1 + n2;
            int temp = n2;
            n2 = n3;
            n1 = temp;
        }
        if(n == 1 || n == 2){
            System.out.println("1");
        }else
        {
            System.out.println(n3);
        }

    }
    public static int oneJie(int num){
        int result = 1;
        for (int i = 1; i <= num; i++) {
             result*= i;
        }
        return result;
    }
    public static void main4(String[] args) {
        //求1！+2！+3！+4！+........+n!的和
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int ret = oneJie(i);
            sum += ret;
        }
        System.out.println(sum);
    }
    public static void main3(String[] args) {
        //求 N 的阶乘 。
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = 1;
        for (int i = 1; i <= n ; i++) {
            ret *= i;

        }
        System.out.println(ret);

    }
   /*创建方法求两个数的最大值max2，随后再写一个求3个数的最大值的函数max3。
    要求：在max3这个函数中，调用max2函数，来实现3个数的最大值计算*/
   public static int max2(int a,int b){
       return (a>b?a:b);
    }
    public  static int max3(int x,int y,int z){
        int ret1=0;
        ret1=max2(x,y);
        int ret2=0;
        ret2=max2(ret1,z);
        return ret2;
    }
   public static void main2(String[] args) {
       Scanner scanner = new Scanner(System.in);
       int num1 = scanner.nextInt();
       int num2 = scanner.nextInt();
       int num3 = scanner.nextInt();
       int ret=max3(num1,num2,num3);
       System.out.println(ret);
   }
    //打印X图形
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()){//多组输入
            int num = scanner.nextInt();
            for (int i = 0; i < num; i++) {
                for (int j = 0; j < num; j++) {
                    if(i == j || i + j == num-1){
                        System.out.print("*");
                    }else{
                        System.out.print(" ");
                    }

                }
                System.out.println();//打印完一行要换行

            }
        }
    }
}
